package com.wsm.springcloud_compose.compose_user_consumer_ribbon.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.wsm.springcloud_compose.compose_user_bean.response.SysUsersResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @name: AdminService
 * @Author: wangshimin
 * @Date: 2019-09-01  17:24
 * @Description:
 */
@Service
public class UserService {

    @Autowired
    private RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "error")
    public SysUsersResponse login(String userName) {
        return restTemplate.getForObject("http://COMPOSE-USER-PRODUCE/login?userName=" + userName, SysUsersResponse.class);
    }


    public SysUsersResponse error(String userName) {
        return null;
    }
}